package org.wuliu.Controller;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.wuliu.dao.HebaoDao;
import org.wuliu.dao.PankuDao;
import org.wuliu.pojo.Hebao;
import org.wuliu.pojo.Panku;
import org.wuliu.utils.ResponseResult;

import java.util.List;

@Controller
@RequestMapping("/hebao")
@CrossOrigin(value = "*")
public class HeBaoController {
    @Autowired
    HebaoDao hebaoDao;

    @RequestMapping("/list")
    @ResponseBody
    public ResponseResult list(@RequestParam(defaultValue = "1") int page, @RequestParam(defaultValue = "5") int limit) throws  Exception{
        Page<Hebao> pager = PageHelper.startPage(page,limit);
        List<Hebao> list= hebaoDao.getAll();
        return new ResponseResult(pager.getTotal(),list);
    }


}
